<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

<#include "../../common/header.html">

<script src="${resurcePath}/cloudpay/js/uploadPreview/uploadPreview.min.js"></script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">

		<!-- 	顶部和左侧菜单的jsp s -->
		<#include "../../common/menu.html">
		<!-- 	顶部和左侧菜单的jsp e -->

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>编辑卡片</h1>
			</section>

			<!-- Main content -->
			<section class="content" style="padding-bottom: 0px;" id="content">
				<!-- general form elements -->
				<div class="box box-primary" style="width: 1000px; margin: 0 auto;">
					<div class="box-header with-border">
						<h3 class="box-title">卡片信息</h3>
					</div>
					<!-- /.box-header -->
					<!-- form start -->
					<form action="/hicatcard/card/editCard" method="post" id="roleForm"  enctype="multipart/form-data">
					   	    
							<div class="box-body">
							<div class="form-group">
								<label for="cardId">卡片标识</label>
								<input type="text" class="form-control" id="cardId" name="cardId" value="${Request.card.cardId!}" readonly="readonly"/> 
							</div>
							<div class="form-group">
								<label for="cardName">卡片名称</label>
								<input type="text" class="form-control" id="cardName" name="cardName" value='${Request.card.cardName!}'/>
							</div>
							
							<div class="form-group">
								<label for="type">类型</label> 
								<select class="form-control select2" style="width: 100%;" name="type" id="type">
									<#list typeMap?keys as key>
 										<option value="${key}" <#if (card.type?? && key?? )&&(card.type?string == key)>selected="selected"</#if>>${typeMap[key]!}</option> 									
 									</#list>
								</select>
							</div> 
							
							<div class="form-group">
								<label for="parentId">商户<font color="red">(第三方卡时候这个这个字段有意义)</font></label> 
									<select class="form-control select2" style="width: 100%;" name="merchantIds" id="merchantIds" multiple="true">
										<#list merchantList as merchant>										
 		 									<option value="${merchant.merchantId}" <#if (card.merchantId?? && merchant.merchantId??)&&(card.merchantId?contains(merchant.merchantId?string))>selected="selected"</#if>>${merchant.name!""}</option>									
										</#list>
									</select>
							</div>
							
							<!-- <div class="form-group">
								<label for="parentId">有效期</label> 
								<select class="form-control select2" style="width: 100%;" name="effectiveDay" id="effectiveDay">
								        <option value="30"  <#if (card.effectiveDay??)&&(card.effectiveDay == 15)>selected="selected"</#if> >半个月</option>																			
 		 								<option value="30"  <#if (card.effectiveDay??)&&(card.effectiveDay == 30)>selected="selected"</#if> >1个月</option>
 		 								<option value="60"  <#if (card.effectiveDay??)&&(card.effectiveDay == 60)>selected="selected"</#if> >2个月</option>		
 		 								<option value="90"  <#if (card.effectiveDay??)&&(card.effectiveDay == 90)>selected="selected"</#if> >3个月</option>		
 		 								<option value="120" <#if (card.effectiveDay??)&&(card.effectiveDay == 120)>selected="selected"</#if> >4个月</option>		
 		 								<option value="150" <#if (card.effectiveDay??)&&(card.effectiveDay == 150)>selected="selected"</#if> >5个月</option>		
 		 								<option value="180" <#if (card.effectiveDay??)&&(card.effectiveDay == 180)>selected="selected"</#if> >6个月</option>		
 		 								<option value="210" <#if (card.effectiveDay??)&&(card.effectiveDay == 210)>selected="selected"</#if> >7个月</option>		
 		 								<option value="240" <#if (card.effectiveDay??)&&(card.effectiveDay == 240)>selected="selected"</#if> >8个月</option>		
 		 								<option value="270" <#if (card.effectiveDay??)&&(card.effectiveDay == 270)>selected="selected"</#if> >9个月</option>		
 		 								<option value="300" <#if (card.effectiveDay??)&&(card.effectiveDay == 300)>selected="selected"</#if> >10个月</option>		
 		 								<option value="330" <#if (card.effectiveDay??)&&(card.effectiveDay == 330)>selected="selected"</#if> >11个月</option>		
 		 								<option value="360" <#if (card.effectiveDay??)&&(card.effectiveDay == 360)>selected="selected"</#if> >12个月</option>																					
								</select>
							</div> -->
							
							<div class="form-group">
								<label for="cardName">有效期(单位：天)</label>
								<input type="text" class="form-control" id="effectiveDay" name="effectiveDay" value='${Request.card.effectiveDay!}'/>
							</div>
							
							<div class="form-group">
								<label for="phone">卡片价格(单位:元)</label>
								<#if Request.card.fee??>
								<input type="text" class="form-control" id="fee" name="fee" value='${Request.card.fee?c!}'/>
							    <#else>
							    <input type="text" class="form-control" id="fee" name="fee" value='${Request.card.fee!}'/>
							    </#if>
							</div>
							<div class="form-group">
								<label for="detail">卡片介绍</label>
								<input type="text" class="form-control" id="detail" name="detail" value='${Request.card.detail!}'/>								
							</div>

							<div class="form-group">
								<label for="cardtPic">卡片图片</label>
								<img <#if Request.card.pictureUlr??>src="${Request.card.pictureUlr!}"</#if> id="img_cardPic" style="width:160px;height:100px;"/> 
								<input type="file" class="form-control" id="cardPic" name="cardPic" style="display:none;" />
							</div>
							
							<div class="form-group">
								<label for="cardtPic">购卡页图片</label>
								<img <#if Request.card.detailBackgroundUrl??>src="${Request.card.detailBackgroundUrl!}"</#if> id="img_cardBackgroundPic" style="width:160px;height:100px;"/> 
								<input type="file" class="form-control" id="cardBackgroundPic" name="cardBackgroundPic" style="display:none;" />
							</div>
							
						    <div class="form-group">
								<label for="cardtPic">领卡页图片</label>
								<img <#if Request.card.gainBackgroundUrl??>src="${Request.card.gainBackgroundUrl!}"</#if> id="img_cardGainBackgroundPic" style="width:160px;height:100px;"/> 
								<input type="file" class="form-control" id="cardGainBackgroundPic" name="cardGainBackgroundPic" style="display:none;" />
							</div> 
							
							<div class="form-group">
								<label for="cardtPic">卡包页图片</label>
								<img <#if Request.card.cardbagUrl??>src="${Request.card.cardbagUrl!}"</#if> id="img_cardbagPic" style="width:160px;height:100px;"/> 
								<input type="file" class="form-control" id="cardbagPic" name="cardbagPic" style="display:none;" />
							</div> 
							
							<#if Request.card.cardId??>
							<#else>
							<div class="form-group">
								<label for="parentId">可选服务项</label> 
									<select class="form-control select2" style="width: 100%;" name="serviceId" id="serviceId">
										<#list serviceList as service>										
 		 									<option value="${service.serviceId}">${service.serviceName}</option>									
										</#list>
								</select>
							</div>
							<div class="form-group">
								<label for="serviceTime">次数</label>
								<input type="text" class="form-control" id="serviceTime" name="serviceTime"/>
							</div>
							</#if>
						
							<div class="form-group">
								<label for="type">赠送优惠券</label> 
								<select class="form-control select2" style="width: 100%;" name="couponId" id="couponId">
									<option value="">不赠送优惠券</option>
									<#list couponList as coupon>										
 										<option value="${coupon.couponId}" <#if (coupon.couponId?? && card.couponId??)&&(card.couponId == coupon.couponId )>selected="selected"</#if>>${coupon.couponName!}</option> 									
 									</#list>
								</select>
							</div>							
					    	<div class="form-group">
								<label for="type">状态</label> 
								<select class="form-control select2" style="width: 100%;" name="status" id="status">
									<#list statusMap?keys as key>
 										<option value="${key}" <#if (card.status?? && key?? )&&(card.status?string == key)>selected="selected"</#if>>${statusMap[key]!}</option> 									
 									</#list>
								</select>
							</div> 
							<div class="form-group">
								<label for="type">兑换页状态</label> 
								<select class="form-control select2" style="width: 100%;" name="changePageStatus" id="changePageStatus">
									<#list statusMap?keys as key>
 										<option value="${key}" <#if (card.changePageStatus?? && key?? )&&(card.changePageStatus?string == key)>selected="selected"</#if>>${statusMap[key]!}</option> 									
 									</#list>
								</select>
							</div>
							<div class="form-group">
								<label for="type">停用状态</label> 
								<select class="form-control select2" style="width: 100%;" name="lockStatus" id="lockStatus">
									<#list lockStatusMap?keys as key>
 										<option value="${key}" <#if (card.lockStatus?? && key?? )&&(card.lockStatus?string == key)>selected="selected"</#if>>${lockStatusMap[key]!}</option> 									
 									</#list>
								</select>
							</div>
							<div class="form-group">
								<label>有效时间:</label>
								<div class="input-group">
								<div class="input-group-addon">
									<i class="fa fa-calendar"></i>
								</div>
									<input type="text" class="form-control pull-right daterange" id="startAndEndDate" name="startAndEndDate" />
								</div>
							</div>	  
							<div class="form-group">
								<label for="order">排序</label>
								<input type="text" class="form-control" id="orderNum" name="orderNum" value='${Request.card.orderNum!}'/>
							</div>
						</div>
						<!-- /.box-body  @click="submit"-->
						<div class="box-footer">
							<button type="submit" class="btn btn-primary">提交</button>
							<button type="reset" class="btn btn-primary" >清空</button>
						</div>
					</form>
				</div>
				<!-- /.box -->
			</section>
			<!-- /.content -->
		</div>

	</div>
	<!-- ./wrapper -->
</body>
<script>
$(function() {
	//校验器
	var formValidator = $("#roleForm").validate({
				onkeyup : false,
				focusInvalid : false,  //错误时,错误选项不会得到焦点
				focusCleanup : true,   //得到焦点时，清空错误提示信息
				rules : {						
					cardName : {
						required:true
					},
					fee : {
						required:true,
						number:true
					},
					serviceTime : {
						required:true,
						number:true,
						digits:true
					},
				},
				messages : {		
					cardName : {
						required:"请输入卡片名称"
					},
					fee : {
						required:"请输入价格",
						number:"请输入正确的价格"
					},
					serviceTime : {
						required:"请输入次数",
						number:"只能输入数字",
						digits:"只能输入整数"
					}
				}
			});
	
	new uploadPreview({
		UpBtn : "cardPic",
		ImgShow : "img_cardPic"
	});

	$("#img_cardPic").click(function() {
		$("#cardPic").click();
	});
	
	new uploadPreview({
		UpBtn : "cardBackgroundPic",
		ImgShow : "img_cardBackgroundPic"
	});

	$("#img_cardBackgroundPic").click(function() {
		$("#cardBackgroundPic").click();
	});
	
	new uploadPreview({
		UpBtn : "cardGainBackgroundPic",
		ImgShow : "img_cardGainBackgroundPic"
	});

	$("#img_cardGainBackgroundPic").click(function() {
		$("#cardGainBackgroundPic").click();
	});
	
	new uploadPreview({
		UpBtn : "cardbagPic",
		ImgShow : "img_cardbagPic"
	});
	
	$("#img_cardbagPic").click(function() {
		$("#cardbagPic").click();
	});
	
	
	transferFenToYuan("fee");
	doDaterangepicker("startAndEndDate",dateTime2Date("${Request.card.lockStartTime!}"),dateTime2Date("${Request.card.lockEndTime!}"))
});

</script>
</html>